import { useState } from "react";
const useClass = () => {
	const [isActive, setIsActive] = useState(false);
	const handleImg = (e) => {
		e.stopPropagation();//div和img重叠导致img的点击事件失效，阻止事件冒泡
		setIsActive(true);
	}
	const handleBox = () => setIsActive(false);
	const imgClass = isActive ? 'active'  : '';
	const boxClass = isActive ? 'box' : 'box boxActive';

	return { handleImg, handleBox, imgClass, boxClass }
}

export default useClass;